<template>
    <div class="ReportImage_div">
        <a-row id="ReportImage_row1" class="ReportImage_row1">
            <a-col :span="24" class="ReportImage_col"><!--takeFromGallery-->
                <el-button type="info"  id="ReportImage_btn1" v-on:click="chooseImageThenCompress" class="ReportImage_btn1" >
                    本地选择
                </el-button>
            </a-col>
        </a-row>

        <a-row id="ReportImage_row2" class="ReportImage_row1">
            <a-col :span="24" class="ReportImage_col">
                <el-button type="info"  id="ReportImage_btn"  v-on:click="takeImage"  class="ReportImage_btn1" >
                    拍摄照片
                </el-button>
            </a-col>
        </a-row>

        <a-row>
            <a-col :span="24" class="showTextCol">
                <!--<div class="showTextOkDiv" v-if="isOk==='1'">{{myFileName}}上传文件成功</div>
                <div class="showTextFailDiv" v-if="isOk==='0'">{{myFileName}}上传文件失败</div>-->
                <br/>
                <div class="progress_line_div" v-for="currFile in fileList">
                    <div class="progress_line_div_text">
                        <div class="progress_line_nullState_fileName" >{{currFile.fileName}}
                            <span v-if="currFile.isUploadOk===true" class="progress_line_ok_fileName">上传成功</span>
                            <span v-if="currFile.isUploadOk===false" class="progress_line_fail_fileName">上传失败</span>
                        </div>
                    </div>
                    <div class="progress_line_div_bar">
                        <el-progress :show-text="true" :text-inside="true" :stroke-width="18" :percentage="currFile.progress" style="text-align: center">
                        </el-progress>
                    </div>

                </div>
            </a-col>
        </a-row>

        <!--<div class="showBox" v-if="Loading" >
            <div class="loading"></div>
            <div class="progress_div">{{progress}}</div>
        </div>-->
    </div>
</template>
<style>
    .progress_line_div{
        width: 100vw;
        height: 14vw;
        margin: 0 0 1vw 0;
        padding: 0 0 0 2vw;
    }
    .progress_line_ok_fileName{
        color: indianred;
    }
    .progress_line_fail_fileName{
        color: rgb(147,147,147);
    }
    .progress_line_nullState_fileName{
        float: left;
        width: 100vw;
        text-align: left;
        font-size: 4.5vw;
        color: black;
    }
    .progress_line_div_bar{
        float: left;
        width: 90vw;
        height: 6vw;
        line-height: 6vw;
    }

    .loading {
        width: 20vw;
        height: 20vw;
        border-radius: 100%;
        border: 5px #ffffff solid;
        border-right-color: dodgerblue;
        animation: loading 1s linear infinite;
        margin: auto;
        z-index: 1000;

    }

    @keyframes loading {
        0% {
            transform: rotate(0deg);
        }
        100% {
            transform: rotate(360deg);
        }
    }
    .showBox{
        padding: 45vh 0 0 0 ;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 100;
        top: 0;
        left: 0;
        position: absolute;
    }
    .ReportImage_div{
        background: rgba(237,237,237,0.3);
        min-height: 100vh;
        width: 100vw;
        padding-top: 5vw;
        overflow: auto;
    }
    .ReportImage_row1{
        width: 100vw;
    }
    .ReportImage_btn1{
        width: 80vw;
        height: 20vw;
        border-radius: 2vw;
        font-size: 8vw;
    }
    #ReportImage_btn1{
        margin: 5vw 0 2vw 0;
    }
    .showTextCol{
        width: 100vw;
        height: 12vw;
        text-align: center;
        margin: 5vw 0 0 0 ;
    }
    .showTextOkDiv{
        width: 100vw;
        height: 12vw;
        line-height: 12vw;
        color: #13ce66;
        font-size: 7vw;
        generic-family: PingFangSC-Semibold;
    }
    .showTextFailDiv{
        width: 100vw;
        height: 12vw;
        line-height: 12vw;
        color: red;
        font-size: 7vw;
        generic-family: PingFangSC-Semibold
    }
</style>
<script>
    import ARow from "ant-design-vue/es/grid/Row";
    import axios from 'axios';
    import {mapState,mapActions,mapGetters} from 'vuex';
    import lrz from 'lrz';
    import ACol from "ant-design-vue/es/grid/Col";

    export default {
        name: "ReportImage",
        components: {ACol, ARow},
        computed: {
            ...mapState(['Loading']),
            ...mapGetters(["fileId"]),

        },
        data() {
            return {
                msg: 'hello vue',
                latitude: "",
                longitude: "",
                sid: localStorage.getItem("sid"),
                workModeId: localStorage.getItem("workModeId"),
                Authorization: localStorage.getItem("userToken"),
                reportHistory: localStorage.getItem("reportHistory") ? JSON.parse(localStorage.getItem("reportHistory")) : [],
                myVideoInfo: {},
                isOk: "",
                progress: '',//当前文件的进度
                fileURL: "",//当前文件的路径
                myFileName: '',//当前文件名称
                createTime: '',//拍摄文件/上传历史保存时间
                gis4_imei: localStorage.getItem("gis4_imei"),
                gis4_phone: localStorage.getItem("gis4_phone"),
                params: {},
                nowTime:'',
                el_progress:'',
                fileList:[],
                isUploadOk:'',
            }
        },
        methods: {
            //多媒体选择器拍摄照片返回压缩图片
            takeImage() {
                let me = this;
                console.log('我要拍摄图片');
                let success = function (result) {
                    console.log("拍摄图片成功", result);

                    if (result.length > 0) {
                        //是否有上传记录，有则清空
                        if(me.fileList.length>0){
                            if(me.fileList[0].isUploadOk!==""||typeof (me.fileList[0].isUploadOk)==="undefined") {
                                me.fileList = [];
                            }
                        }
                        //me.$store.commit('showLoading'); //打开遮罩
                        //返回的数据一个为jsonArray，一个图片有未压缩地址filePath和压缩地址compressPath，循环得乘以2
                        for(let i = 0;i<(result.length)/2;i++){
                            me.fileURL = result[2*i+1];//这里取压缩地址，未压缩地址为：result[2*i]
                            let arrName = result[2*i+1].split("/");
                            me.myFileName = arrName[(arrName.length) - 1];
                            //me.getLocaltion();//调用获取经纬度的方法，然后上传文件
                            //me.changeTypeAndUpload(me.fileURL)
                            me.fileList.push({fileURL:me.fileURL,fileName:me.myFileName,progress:0,isUploadOk:''});
                        }
                        me.sureContinue();//确认是否继续拍照

                        //百度定位请求经纬度信息
                        me.nowTime = new Date();
                        me.createTime = me.getFormatTimeLine(me.nowTime);
                        me.getCooUsingBaiduSdk().then(result => {
                            me.latitude = result.latitude;
                            me.longitude = result.longitude;
                            me.params = {
                                LongitudeGcj02: result.longitude,//LongitudeBd09
                                LatitudeGcj02: result.latitude,//LatitudeBd09
                                userId: me.sid,
                                workModeId: me.workModeId,
                                time: me.createTime,
                            };
                        }).catch(error => {
                            //me.$store.commit('hideLoading');
                            console.log("getCooUsingBaiduSdk error:",error);
                            me.$alert("定位信息未获取");
                            return ;
                        });
                    }

                };
                let fail = function (error) {
                    me.myVideoInfo.isOk = "0";
                    me.$store.commit('hideLoading'); //关闭遮罩
                    console.log("拍摄图片失败", error);
                };
                myMediaPlugin.takeImage(success, fail, {});
            },
            sureContinue(){
                let me = this;
                let title = "拍照选择";
                let message = "还要拍照？";
                let buttonLabels = ["继续拍照","立即上传"];//出现界面：2取消 1确认
                navigator.notification.confirm(message, confirmCallback, title, buttonLabels);
                function confirmCallback(buttonIndex) {
                    if(buttonIndex===1){
                        console.log("You clicked right button 继续拍照" + buttonIndex);
                        me.takeImage();//继续拍照
                    }else if(buttonIndex===2){
                        console.log("You clicked left button 立即上传" + buttonIndex);
                        me.changeTypeAndUpload();
                        //立即上传
                    }else{
                        console.log("You clicked left button" + buttonIndex);
                        me.sureContinue();
                    }
                }
            },
            takePhoto() {
                //cordova-plugin-media-capture插件单选选择本地图片
                let me = this;
                let onCameraSuccess = function(fileURL) {
                    //this.$store.commit('showLoading');
                    me.fileURL = fileURL;
                    console.log("takePhotoSuccess fileURL:", me.fileURL);

                    let arr = me.fileURL.split('/');
                    me.myFileName = arr[arr.length - 1];
                    //调用上传文件插件
                    me.getLocaltion();
                    /*let nowTime = new Date();
                        this.imgUrl = "data:image/jpeg;base64," + imageURL;
                        this.sendPhoto(imageURL,nowTime);原来的方法进行注释*/
                };
                let onCameraError  = function(e) {
                    console.log("onCameraError:" + e);
                    this.$store.commit('hideLoading');
                };
                let cameraOptions = {
                    quality: 100,
                    destinationType: Camera.DestinationType.FILE_URI,//原来方法采用DATA_URL，需要base64转码成Blob上传
                    sourceType: Camera.PictureSourceType.CAMERA,     //照相机类型
                    allowEdit: false,
                    encodingType: Camera.EncodingType.JPEG,
                    /*targetWidth : 100,
                        targetHeight : 100,*/
                    SaveToPhotoAlburn: true,//捕获后将图像保存到设备上的相册中。
                    popoverOptions: CameraPopoverOptions,
                    saveToPhotoAlbum: true,
                    correctOrientation: true,
                };
                console.log("调用拍照接口");
                navigator.camera.getPicture(onCameraSuccess, onCameraError, cameraOptions);
            },
            takeFromGallery() {
                //cordova-plugin-media-capture插件单选选择本地图片
                let me = this;
                let onCameraSuccess = function(fileURL) {
                    //this.$store.commit('showLoading');
                    me.fileURL = fileURL;
                    console.log("takePhotoSuccess fileURL:", me.fileURL);

                    let arr = me.fileURL.split('/');
                    me.myFileName = arr[arr.length - 1];
                    //调用上传文件插件
                    me.getLocaltion();
                    /*let nowTime = new Date();
                        this.imgUrl = "data:image/jpeg;base64," + imageURL;
                        this.sendPhoto(imageURL,nowTime);原来的方法进行注释*/
                };
                let onCameraError  = function(e) {
                    console.log("onCameraError:" + e);
                    this.$store.commit('hideLoading');
                };
                let cameraOptions = {
                    quality: 100,
                    destinationType: Camera.DestinationType.DATA_URL,//原来方法采用DATA_URL，需要base64转码成Blob上传
                    sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,    //相册类型
                    allowEdit: false,
                    encodingType: Camera.EncodingType.JPEG,
                    mediaType: Camera.MediaType.PICTURE,
                    /*targetWidth : 100,
                        targetHeight : 100,*/
                    popoverOptions: CameraPopoverOptions,
                    saveToPhotoAlbum: false,
                    correctOrientation: true,
                    myFileName: '',
                };
                console.log("调用navigator.camera相册接口");
                navigator.camera.getPicture(onCameraSuccess, onCameraError, cameraOptions);
            },
            /*sendPhoto(imageURL,nowTime) {
            //URL获取到的是Base64,最初formData上传的方式
                    let formData = new FormData();

                    let getBlob = this.convertBase64UrlToBlob(imageURL);
                    let file = this.blobToFile(getBlob);

                    let fileName = this.getFileTime(nowTime)+".jpg";
                    let createTime = this.getFormatTimeLine(nowTime);
                    let isOk = "";

                    formData.append("file",file,fileName);
                    formData.append('longitude',this.longitude);
                    formData.append('latitude',this.latitude);
                    formData.append('userId',this.sid);
                    formData.append('workModeId',this.workModeId);
                    formData.append("time",createTime);
                    /!*formData.append("file",this.convertBase64UrlToBlob(imageURL));*!/
                    console.log(file);
                    console.log(formData.get('file'));
                    let config = {
                        headers: {
                            "Content-Type":'multipart/form-data',
                            "Authorization":this.Authorization,
                        },
                    }
                    axios.post('http://app.gis4.tdzcsoft.com:7000/app/work/upload',formData,config).then(res=> {
                        if(res.status === 200){
                            this.myPhotoInfo.fileName = fileName;
                            this.myPhotoInfo.createTime = createTime;
                            this.myPhotoInfo.isOk = "1";
                            this.myPhotoInfo.sid = this.sid;
                            this.reportHistory.unshift(this.myPhotoInfo);
                            localStorage.setItem("reportHistory",JSON.stringify(this.reportHistory));//保存进内存
                            this.$store.commit('hideLoading');
                            this.isOk = "1";
                        }
                    }).catch((error) =>{
                                console.log("照片信息提交失败");
                                console.log(error);
                                this.myPhotoInfo.fileName = fileName;
                                this.myPhotoInfo.createTime = createTime;
                                this.myPhotoInfo.isOk = "0";
                                this.myPhotoInfo.sid = this.sid;
                                this.reportHistory.unshift(this.myPhotoInfo);
                                localStorage.setItem("reportHistory",JSON.stringify(this.reportHistory));//保存进内存
                                this.$store.commit('hideLoading');
                                this.isOk = "0";
                            })
                },

                convertBase64UrlToBlob(imageURI) {
                    let bytes = window.atob(imageURI); //去掉url的头，并转换为byte
                    //处理异常,将ascii码小于0的转换为大于0
                    let ab = new ArrayBuffer(bytes.length);
                    let ia = new Uint8Array(ab);
                    for(let i = 0; i < bytes.length; i++) {
                        ia[i] = bytes.charCodeAt(i);
                    }
                    return new Blob([ab], { type: 'image/jpeg' });
                },
                blobToFile(theBlob,fileName) {
                    //将blob转换为file
                        theBlob.lastModifiedDate = new Date();
                        theBlob.name = fileName;
                        return theBlob;
                },*/
            getFileTime(date) {
                let complement = function (n) {
                    return n < 10 ? '0' + n : n
                };
                //输出文件名
                return date.getFullYear().toString() + complement(date.getMonth() + 1) +
                    complement(date.getDate()) + complement(date.getHours()) +
                    complement(date.getMinutes()) + complement(date.getSeconds());
            },
            getFormatTimeLine(date) {
                //获取一个现在的时间
                let complement = function (n) {
                    return n < 10 ? '0' + n : n
                };
                //返回格式2019-07-09 09:53:08
                return date.getFullYear().toString() + "-" + complement(date.getMonth() + 1) + "-" +
                    complement(date.getDate()) + " " + complement(date.getHours()) + ":" +
                    complement(date.getMinutes()) + ":" + complement(date.getSeconds());
            },
            //绑定显示上传进度
            selectload(e) {
                let me = this;
                if (e.lengthComputable) {
                    // this.sheetVisible=true;
                    let num = (e.loaded / e.total) * 100;
                    me.progress = num.toFixed(2) + "%";
                    /*console.log('当前进度：' + e.loaded / e.total);0.97*/
                }
            },
            getLocaltion() {
                let me = this;
                let nowTime = new Date();
                me.createTime = me.getFormatTimeLine(nowTime);
                me.getCooUsingBaiduSdk().then(result => {
                    //判断经纬度是否为空
                    if(result.longitude===""||typeof (result.longitude)==="undefined"){
                        result.longitude = localStorage.getItem("longitude");
                        result.latitude = localStorage.getItem("latitude");
                    }
                    me.params = {
                        LongitudeGcj02: result.longitude,//LongitudeBd09
                        LatitudeGcj02: result.latitude,//LatitudeBd09
                        userId: me.sid,
                        workModeId: me.workModeId,
                        time: me.createTime,
                    };
                    me.$store.commit("updateLatitude",result.latitude);
                    me.$store.commit("updateLongitude",result.longitude);
                    me.beginUpload();
                }).catch(error => {
                    console.log(error);
                    me.$store.commit('hideLoading');
                });
            },
            getCooUsingBaiduSdk() {
                /*, ScanSpan: 0*/
                let params = {
                    CoorType: "gcj02",
                    OpenAutoNotifyMode: true,
                    Interval: 5000,
                    Distance: 1,
                    LocationNotify: true
                };//bd09ll,gcj02,
                return new Promise((resolve, reject) => {
                    if (typeof (baidumap_location) !== "undefined") {//if判断是为了兼容浏览器调试不报错
                        try {
                            baidumap_location.getCurrentPosition((result) => {
                                /*console.log(`baidu coo: ${result.longitude},${result.latitude}`);*/
                                //理解resolve，将结果放入resolve作为参数传给成功回调的参数,如，if(num<=5){resolve(num);}else{reject('数字太大了');}
                                resolve(result)
                            }, (error) => {
                                console.log("getCooUsingBaiduSdk", error);
                                reject(error)
                            }, params);
                        } catch (e) {
                            console.log("getCooUsingBaiduSdk catch", e);
                            reject(e)
                        }
                    }//if end

                })
            },
            beginUpload() {
                //这是本地媒体选择器选择后在经纬度获取方法中所调用的上传文件功能
                let me = this;
                //上传成功的回调方法
                let win = function (r) {
                /*  console.log(r);
                    console.log("Code = " + r.responseCode);
                    console.log("Sent = " + r.bytesSent);
                */
                    console.log("Response = " + r.response);

                    //将上传信息放入本地上传历史资料信息显示
                    me.$store.commit('hideLoading');
                    me.isOk = "1";
                    me.myVideoInfo.fileName = me.myFileName;
                    me.myVideoInfo.createTime = me.createTime;
                    me.myVideoInfo.sid = me.sid;
                    me.myVideoInfo.isOk = "1";
                    me.reportHistory.push(me.myVideoInfo);
                    localStorage.setItem("reportHistory", JSON.stringify(me.reportHistory));//保存进内存
                };
                //上传失败的回调方法
                let fail = function (error) {
                    console.log("视频拍摄上传失败", error);
                    /*console.log("An error has occurred: Code = " + error.code);
                        console.log("upload error source " + error.source);
                        console.log("upload error target " + error.target);*/
                    me.$store.commit('hideLoading');
                    me.isOk = "0";
                    me.myVideoInfo.fileName = me.myFileName;
                    me.myVideoInfo.createTime = me.createTime;
                    me.myVideoInfo.isOk = "0";
                    me.myVideoInfo.sid = me.sid;
                    me.reportHistory.push(me.myVideoInfo);
                    localStorage.setItem("reportHistory", JSON.stringify(me.reportHistory));//保存进内存
                };
                //上传参数
                let options = new FileUploadOptions();
                options.fileKey = 'file';
                options.fileName = me.fileURL.substr(me.fileURL.lastIndexOf('/') + 1);
                options.mimeType = "image/jpeg";
                let headers = {
                    "Authorization": me.Authorization,
                    "gis4_imei": me.gis4_imei,
                    "gis4_time": new Date().getTime(),
                    "gis4_phone": me.gis4_phone,
                    "planNo":me.$store.state.planNo,
                    /*"Content-Type":'multipart/form-data'*/
                };
                options.headers = headers;
                options.params = me.params;
                //实例化上传类
                let ft = new FileTransfer();
                //绑定上传进度函数
                ft.onprogress = me.selectload;
                //开始上传 上传插件方法调用
                console.log("上传源路径:", me.fileURL);
                ft.upload(me.fileURL, encodeURI('http://'+localStorage.getItem("apiHost")+'/app/work/upload'), win, fail, options);

            },
            chooseImage() {
                //主流仿微信npm上cordova-plugin-vha-mediapicker图片选择器插件
                //该插件已卸载，因为和自定义多媒体选择器插件类冲突报错，两者选其一
                let me = this;
                    let resultMedias=[];
                    let args = {
                        'selectMode': 100, //100=image , 101=picker image and video , 102=video
                        'maxSelectCount': 1, //default 40 (Optional)
                        'maxSelectSize': 10485760, //10M,188743680=180M (Optional) only android

                    };
                    let pickerOk = function(medias){
                        //medias [{mediaType: "image", path:'/storage/emulated/0/DCIM/Camera/2017.jpg', uri:"android retrun uri,ios retrun URL" size: 21993}]
                        resultMedias = medias;
                        console.log(resultMedias);
                        if(resultMedias.length>0){
                            me.$store.commit('showLoading'); //打开遮罩
                            me.myFileName =resultMedias[0].name;//赋值data文件名称
                            me.fileURL = resultMedias[0].uri;
                            me.getLocaltion();
                        }
                        /*me.getThumbnail(medias,imgs);返回创建缩略图*/
                    }
                    let pickerFail = function (e){
                        me.$store.commit('hideLoading');//关闭遮罩
                        console.log("音视频选择失败",e)
                    }
                    //调用Picker本地视频选择
                    MediaPicker.getMedias(args,pickerOk, pickerFail);
            },
            chooseImageThenCompress(){
                //通过自定义图片选择器，得到图片压缩/未压缩路径，然后lrz再压缩得到实体文件
                //获取经纬度
                //formData上传
                let me = this;
                let success = function (result) {
                    console.log("选择图片成功:", result);
                    me.fileList = [];//清空上次的文件列表
                    if (result.length > 0) {
                        //me.$store.commit('showLoading'); //打开遮罩
                        //返回的数据一个为jsonArray，一个图片有未压缩地址filePath和压缩地址compressPath，循环得乘以2
                        for(let i = 0;i<(result.length)/2;i++){
                            console.log(result[2 * i]);
                            console.log(result[2 * i + 1]);
                            me.fileURL = result[2 * i + 1];//这里取压缩地址，未压缩地址为：result[2*i]
                            let arrName = result[2 * i + 1].split("/");//这里做文件转换测试 用未压缩路径
                            me.myFileName = arrName[(arrName.length) - 1];
                            /*me.getLocaltion();*/
                            //测试转换blob
                            me.fileList.push({fileURL:me.fileURL,fileName:me.myFileName,progress:0,isUploadOk:''});
                        }
                        //百度定位请求经纬度信息
                        me.nowTime = new Date();
                        me.createTime = me.getFormatTimeLine(me.nowTime);
                        me.getCooUsingBaiduSdk().then(result => {
                            if(result.longitude===""||typeof (result.longitude)==="undefined"){
                                result.longitude = localStorage.getItem("longitude");
                                result.latitude = localStorage.getItem("latitude");
                            }
                            me.latitude = result.latitude;
                            me.longitude = result.longitude;
                            me.params = {
                                LongitudeGcj02: result.longitude,//LongitudeBd09
                                LatitudeGcj02: result.latitude,//LatitudeBd09
                                userId: me.sid,
                                workModeId: me.workModeId,
                                time: me.createTime,
                            };
                            me.$store.commit("updateLatitude",result.latitude);
                            me.$store.commit("updateLongitude",result.longitude);
                        }).catch(error => {
                            me.$store.commit('hideLoading');
                            console.log("getCooUsingBaiduSdk error:",error);
                            me.$alert("定位数据等待获取");
                            return ;
                        });
                        me.changeTypeAndUpload();//通过data的fileList中的path在lrz插件中得到压缩的实体对象
                    }
                };
                let fail = function (error) {
                    //me.$store.commit('hideLoading');//关闭遮罩
                    console.log("返回选择结果失败:", error);
                };
                myMediaPlugin.selectImage(success, fail,{maxNumber:99,minNumber:1,quality:60,rowNumber:3,});
            },
            changeTypeAndUpload(){
                //通过自定义图片选择器，得到图片压缩/未压缩路径，然后lrz再压缩得到实体文件
                //获取经纬度
                //formData上传
                let me = this;
                for(let i = 0;i<me.fileList.length;i++){
                    console.log(me.fileList[i].fileURL);
                    lrz( me.fileList[i].fileURL, {width:1080,height:1920,quality:0.6}).then(function(rst) {
                        //lrz前端H5插件
                        //{formData: FormData, fileLen: 13751, base64: "…t7/9k=",
                        // base64Len: 18359, origin: "/storage/emulated/0/DCIM/Camera/IMG_20190708_211250.jpg"}
                        //console.log("lrz插件压缩:",rst);
                        let file = rst.file;

                        /*let fileName = me.getFileTime(me.nowTime)+".jpg";*/
                        let formData = new FormData();
                        formData.append("file",file,me.fileList[i].fileName);//me.myFileName
                        formData.append('LongitudeGcj02',me.longitude);
                        formData.append('LatitudeGcj02',me.latitude);
                        formData.append('userId',me.sid);
                        formData.append('workModeId',me.workModeId);
                        formData.append("time",me.createTime);
                        //console.log("formData get file:",formData.get('file'));
                        console.log("get formData file ok");
                        console.log(me.fileList);
                        let configs = {
                            headers: {
                                "Content-Type":'multipart/form-data',
                                "Authorization":me.Authorization,
                                "WorkPlanNo":me.$store.state.planNo,
                                "gis4_longitude":localStorage.getItem("longitude"),
                                "gis4_latitude": localStorage.getItem('latitude'),
                                "gis4_imei" : localStorage.getItem('gis4_imei'),
                                "gis4_phone" : localStorage.getItem('gis4_phone'),
                                "version" : localStorage.getItem('version'),
                                "gis4_workmode" :localStorage.getItem('workModeId'),
                                "gis4_time":new Date().getTime(),
                            },
                            onUploadProgress: (progressEvent) => {
                                // 使用本地 progress 事件
                                if (progressEvent.lengthComputable) {
                                    let num = Math.round((progressEvent.loaded / progressEvent.total) * 100);
                                    me.fileList[i].progress = num.toFixed(2) ;// 使用某种 UI 进度条组件会用到的百分比
                                    console.log(me.progress);
                                }
                            }
                        };

                        axios.post('http://'+localStorage.getItem("apiHost")+'/app/work/upload',formData,configs).then(res=> {
                            if(res.status === 200){
                                me.myVideoInfo.fileName = me.fileList[i].fileName;
                                me.myVideoInfo.createTime = me.createTime;
                                me.myVideoInfo.isOk = "1";
                                me.myVideoInfo.sid = me.sid;
                                me.reportHistory.push(me.myVideoInfo);
                                me.isOk = "1";
                                me.fileList[i].isUploadOk = true;
                                localStorage.setItem("reportHistory",JSON.stringify(me.reportHistory));//保存进内存

                            }
                        }).catch((error) =>{
                            console.log("照片信息提交失败");
                            console.log(error);
                            me.myVideoInfo.fileName = me.fileList[i].fileName;
                            me.myVideoInfo.createTime = me.createTime;
                            me.myVideoInfo.isOk = "0";
                            me.myVideoInfo.sid = me.sid;
                            me.reportHistory.push(me.myVideoInfo);
                            me.isOk = "0";
                            me.fileList[i].isUploadOk = false;
                            localStorage.setItem("reportHistory",JSON.stringify(me.reportHistory));//保存进内存
                        })
                    }).catch(function(error) {
                        console.log(error);
                        me.fileList[i].isUploadOk = false;
                        //失败时执行
                    }).always(function() {
                        //不管成功或失败，都会执行
                    });
                }
            },
            addFileInfo(){
                console.log(this.$store.state.fileList);
                let fileList = {
                    id:1,
                    name:"fileList1",
                    title:'文件详情1',
                    detail:{
                        basicInfo:{id:1,fileName:"文件名称1",filePath:"文件路径",mime类型:"",createdTime:"创建日期"},
                        uploadInfo:{isOK:false,progress:0,beginTime:"0000"},
                        aboutInfo:{userId:"",type:"资料上报"}
                    }
                };
                /*this.$store.commit("addFileList",fileList);*/
                this.$store.commit("addFileId");
                console.log(this.fileId);
                console.log(this.$store.state.fileList);
            },



        },//method方法结束

    }
</script>